const express = require("express");
const app = express();
//设置服务器跨域权限
app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
  res.header("Content-Type", "application/json;charset=utf-8");
  //用于判断request来自ajax还是传统请求
  res.header(
    "Access-Control-Allow-Headers",
    " Origin, X-Requested-With, Content-Type, Accept"
  );
  next();
});
//图片太大
app.use(express.json({ limit: "10mb" }));
app.use(express.urlencoded({ limit: "10mb", extended: true }));
// 优先访问静态文件
app.use(express.static(__dirname + "/public")); //静态文件访问：http://localhost:88/public/images/logo.png
const router = require("./router");
const router_file = require("./router_file");
//访问路由
app.use(router);
app.use(router_file);
app.listen("90", function() {
  console.log("http://localhost:90");
});
